import request from '@/utils/request'

// 查询巡区用户分配列表
export function listPatrolAreaUser(query) {
  return request({
    url: '/system/patrolAreaUser/list',
    method: 'get',
    params: query
  })
}

// 查询巡区用户分配详细
export function getPatrolAreaUser(id) {
  return request({
    url: '/system/patrolAreaUser/' + id,
    method: 'get'
  })
}

// 根据巡区ID查询用户分配列表
export function getUsersByAreaId(areaId) {
  return request({
    url: '/system/patrolAreaUser/area/' + areaId,
    method: 'get'
  })
}

// 根据用户ID查询巡区分配列表
export function getAreasByUserId(userId) {
  return request({
    url: '/system/patrolAreaUser/user/' + userId,
    method: 'get'
  })
}

// 新增巡区用户分配
export function addPatrolAreaUser(data) {
  return request({
    url: '/system/patrolAreaUser',
    method: 'post',
    data: data
  })
}

// 修改巡区用户分配
export function updatePatrolAreaUser(data) {
  return request({
    url: '/system/patrolAreaUser',
    method: 'put',
    data: data
  })
}

// 删除巡区用户分配
export function delPatrolAreaUser(id) {
  return request({
    url: '/system/patrolAreaUser/' + id,
    method: 'delete'
  })
}

// 批量分配用户到巡区
export function batchAssignUsers(areaId, userIds, userNames, assignType) {
  return request({
    url: '/system/patrolAreaUser/batchAssign',
    method: 'post',
    data: {
      areaId: areaId,
      userIds: userIds,
      userNames: userNames,
      assignType: assignType
    }
  })
}

// 取消用户巡区分配
export function cancelUserAssign(areaId, userId) {
  return request({
    url: '/system/patrolAreaUser/cancel',
    method: 'delete',
    params: {
      areaId: areaId,
      userId: userId
    }
  })
} 